package com.atguigu.juc.day02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;

/**
 * @author atguigu-mqx
 */
public class ThreadPoolDemo {

    public static void main(String[] args) {
        //  主入口： 准备一个业务 银行窗口办理业务！
        //  固定大小线程池！
        ExecutorService executorService = Executors.newScheduledThreadPool(5);
        //  一池一线程！
//        ExecutorService executorService = Executors.newSingleThreadExecutor();
        //  可扩容的线程池！
//        ExecutorService executorService = Executors.newCachedThreadPool();

        for (int i = 0; i < 10; i++) {
            executorService.execute(()->{
                System.out.println(Thread.currentThread().getName()+"处理业务....");
            });
        }
        //  关闭线程池！
        executorService.shutdown();
    }
}
